﻿using Microsoft.AspNet.SignalR;
using Newtonsoft.Json;
using RockBus.Logging.Interfaces;

namespace RockBus.Services.SignalR
{
    public class SignalRConfiguration
    {
        public SignalRConfiguration(ILogger logger)
        {
            this.Logger = logger;
        }

        private ILogger Logger { get; set; }

        public void Configure()
        {
            GlobalHost.DependencyResolver = new SignalRDependencyResolver();
            var settings = new JsonSerializerSettings
            {
                //Formatting = Newtonsoft.Json.Formatting.Indented,
                ContractResolver = new SignalRContractResolver(),
            };

            var jsonNetSerializer = JsonSerializer.Create(settings);
            GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => jsonNetSerializer);
        }
    }
}
